#!/bin/bash
if [! -f "ILSVRC2012_img_train.tar"];then
echo "ILSVRC2012_img_train.tar no exist"
exit
fi
if [! -f "ILSVRC2012_img_val.tar"];then
echo "ILSVRC2012_img_val.tar no exist"
exit
fi
if [-d "train"];then
rm -rf ./train
fi
if [-d "train"];then
rm -rf ./val
fi

mkdir -p train val 
tar -xvf ILSVRC2012_img_train.tar -C train/
tar -xvf ILSVRC2012_img_val.tar -C val/
cd train/
find . -name "*.tar" | while read LINE ; do mkdir -p "${LINE%.tar}"; tar -xvf "${LINE}" -C "${LINE%.tar}"; rm -f "${LINE}"; done
cd ../models/research/slim/datasets/
python3 preprocess_imagenet_validation_data.py ../../../../val/ imagenet_2012_validation_synset_labels.tx

